//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.api.syh56.shengyunhui;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import com.openapi.sdk.service.DataExchangeService;
import com.openapi.sdk.service.TransCode;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Demo {
    public Demo() {
    }

    public static void login() {
        try {
            String p = "user=572512651@qq.com&pwd=07X1jQYO";
            System.out.println("参数:" + p);
            p = TransCode.encode(p);
            String url = "https://zhiyunopenapi.95155.com/apis/login/" + p + "?client_id=417a1452-00ff-4060-af52-f959d5b74374";
            DataExchangeService des = new DataExchangeService(5000, 5000);
            System.out.println("请求地址:" + url);
            String res = des.accessHttps(url, "POST");
            System.out.println("返回:" + res);
        } catch (Exception var5) {
            System.out.println("e:" + var5.getMessage());
        }

    }

    public void queryServiceData() {
        try {
            String p = "token=您的令牌&vclNs=陕YH0009_2";
            System.out.println("参数:" + p);
            p = TransCode.encode(p);
            String url = "https://testopen.95155.com/apis/querySpecifiedLocation/" + p + "?client_id=您的客户端ID";
            DataExchangeService des = new DataExchangeService(5000, 5000);
            System.out.println("请求地址:" + url);
            String res = des.accessHttps(url, "POST");
            System.out.println("返回:" + res);
        } catch (Exception var5) {
            System.out.println("e:" + var5.getMessage());
        }

    }

    public void queryServiceDataV2() {
        try {
            Map<String, String> map = new HashMap(2);
            map.put("token", "2ccf46eb-f187-4018-81cd-b2c5babd8072");
            map.put("srt", "2c66d54c-22b4-412f-9819-136d84aa0371");
            map.put("cid", "11c5c632-5168-4d77-86dc-3d2dd6c419b3");
            map.put("timeNearby", "30");
            map.put("vclN", "陕YH0009");
            String url = "https://devopen.95155.com/save/apis/opGpVclPos";
            DataExchangeService des = new DataExchangeService(5000, 5000);
            System.out.println("请求地址:" + url);
            String res = des.postHttps(url, map);
            System.out.println("返回:" + res);
        } catch (Exception var5) {
            System.out.println("e:" + var5.getMessage());
        }

    }

    public void queryServiceDataV3() {
        try {
            Map<String, String> map = new HashMap(2);
            map.put("token", "77d34740-489d-4244-8955-695a001d6d51");
            map.put("srt", "a498d292-5794-482a-8baf-57306f6db590");
            map.put("cid", "af5e048f-9d77-426e-ac7f-716c782e3026");
            map.put("path", "C:\\Users\\admin\\Desktop\\37.JPG");
            String url = "https://testopen.95155.com/save/apis/vehicleLicense";
            DataExchangeService des = new DataExchangeService(5000, 5000);
            System.out.println("请求地址:" + url);
            String res = des.postHttps(url, map);
            System.out.println("返回:" + res);
        } catch (Exception var5) {
            System.out.println("e:" + var5.getMessage());
        }

    }

    public static void main(String[] args) {
        String bankCode = "ABC";
        String logourl = "";

        Gson gson = new Gson();
        JsonReader reader;
        try {
            reader = new JsonReader(new FileReader("D:\\javaProject\\ShengYunHui\\src\\test\\java\\com\\api\\syh56\\shengyunhui\\banks.json"));
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
        Object obj = gson.fromJson(reader, Object.class);
        // 关闭 JsonReader
        try {
            reader.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        // 使用 Gson 的 toJson 方法，将 Java 对象转换为 JSON 字符串
        String jsonStr = gson.toJson(obj);

        // 将字符串转换为JSON数组
        List<Map> BankList = JSONObject.parseArray(jsonStr, Map.class);
        // 遍历JSON数组
        for (int i = 0; i < BankList.size(); i++) {
            Map map = BankList.get(i);

            String abbrEn = (String) map.get("abbr_en"); // 获取abbr_en值
            if (bankCode.equals(abbrEn)) {
                String icon = (String) map.get("icon"); // 获取icon值
                System.out.println("Icon for " + abbrEn + ": " + icon);
                logourl = "https://syhcomm.oss-cn-beijing.aliyuncs.com/bankicons/"+icon;

                break; // 如果只需要找到第一个匹配项，找到后即可退出循环
            }
        }
    }
}
